package com.ruoyi.web.controller.wq;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqNoticeChat;
import com.ruoyi.wq.domain.vo.WqNoticeChatVO;
import com.ruoyi.wq.service.IWqNoticeChatService;
import com.ruoyi.framework.web.service.NoticeChatService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天通知Controller
 * 
 * @author ruoyi
 * @date 2023-11-08
 */
@RestController
@RequestMapping("/wq/noticeChat")
public class WqNoticeChatController extends BaseController {

    @Autowired
    private IWqNoticeChatService wqNoticeChatService;
    
    @Autowired
    private NoticeChatService noticeChatService;

    /**
     * 查询聊天通知列表
     */
    @GetMapping("/getNoticeList")
    public TableDataInfo getNoticeList(WqNoticeChat wqNoticeChat){
        return wqNoticeChatService.getNoticePageList(wqNoticeChat);
    }

    /**
     * 获取聊天通知详细信息
     */
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(WqNoticeChat wqNoticeChat) {
        return AjaxResult.success(noticeChatService.getNoticeChatById(wqNoticeChat.getId()));
    }
    
    /**
     * 获取未读消息
     */
    @GetMapping(value = "/getNoticeCount")
    public AjaxResult getNoticeCount(WqNoticeChat wqNoticeChat) {
        return AjaxResult.success(noticeChatService.getNoticeCount());
    }

    /**
     * 新增聊天通知
     */
    @RepeatSubmit
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WqNoticeChatVO wqNoticeChat) {
        return AjaxResult.success(noticeChatService.add(wqNoticeChat));
    }
    
    /**
     * 邀请用户认证
     */
    @RepeatSubmit
    @PostMapping("/checkUser")
    public AjaxResult checkUser(@RequestBody WqNoticeChat wqNoticeChat) {
        return noticeChatService.checkUser(wqNoticeChat);
    }
    
    /**
     * 验证领奖
     */
    @RepeatSubmit
    @PostMapping("/checkCode")
    public AjaxResult checkCode(@RequestBody WqNoticeChat wqNoticeChat) {
        return noticeChatService.checkCode(wqNoticeChat);
    }

    /**
     * 修改聊天通知
     */
    @PreAuthorize("@ss.hasPermi('wq:noticeChat:edit')")
    @Log(title = "聊天通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqNoticeChat wqNoticeChat)
    {
        return toAjax(wqNoticeChatService.updateWqNoticeChat(wqNoticeChat));
    }

    /**
     * 删除聊天通知
     */
    @PreAuthorize("@ss.hasPermi('wq:noticeChat:remove')")
    @Log(title = "聊天通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqNoticeChatService.deleteWqNoticeChatByIds(ids));
    }
}
